<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/include.inc.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/views/layout/base.ref.jsp" %>
    <%@include file="/WEB-INF/views/layout/valid.ref.jsp" %>
    <%@include file="/WEB-INF/views/layout/meeting.subgrid.jsp" %>

</head>
<body>
<form method="post" id="form1" action="${ctx}/customsearch/customsearchsetting/save">
    <input type="hidden" name="id" id="id" value="${customsearchSetting.id}"/>
    <%@include file="/WEB-INF/views/login/home/toolbar.jsp" %>
    <div class="mtcontent">
        <div class="mtheader">
            <shiro:hasPermission name="sysConfiguration:edit">
                <a class="mtbtn one" href="#" onclick="save();hrefSave_OnClick('form1')"><i
                        class="mtfa mt-dui"></i><span>保存</span></a>
            </shiro:hasPermission>
            <a class="mtbtn two" href="#" onclick="hrefRet_OnClick('${ctx}/customsearch/customsearchsetting/list')"><i
                    class="mtfa mt-refresh"></i><span>返回</span></a>
        </div>
        <div class="mtbody">
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel">名称 </label> <input type="text" class="mtinput" name="selectName"
                                                              value="${customsearchSetting.selectName}"/>
                </div>
                <div class="mtcol">
                    <label class="mtlabel">编码 </label> <input type="text" class="mtinput" name="selectCode"
                                                              value="${customsearchSetting.selectCode}"/>
                </div>
            </div>
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel">选择类型 </label>
                    <div class="mtinput">
                        <select name="selectType" class="width-80">
                            <option ${customsearchSetting.selectType == 0 ? 'selected="selected"' : ''} value="0">
                                单选/多选
                            </option>
                            <option ${customsearchSetting.selectType == 1 ? 'selected="selected"' : ''} value="1">单选
                            </option>
                            <option ${customsearchSetting.selectType == 2 ? 'selected="selected"' : ''} value="2">多选
                            </option>
                        </select>
                    </div>
                </div>
                <div class="mtcol">
                    <label class="mtlabel">弹框类型 </label>
                    <div class="mtinput">
                        <select name="bouncedType" class="width-80">
                            <option ${customsearchSetting.bouncedType == 0 ? 'selected="selected"' : ''} value="0">列表
                            </option>
                            <option ${customsearchSetting.bouncedType == 1 ? 'selected="selected"' : ''} value="1">树形
                            </option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="mtrow">
                <div class="mtcol2">
                    <label class="mtlabel">SQL语句 </label>
                    <textarea name="sqlMapId" class="mtinput2"
                              style="height: 80px;">${customsearchSetting.sqlMapId}</textarea>
                </div>
            </div>
        </div>
    </div>

    <input type="hidden" id="cols" name="cols" value='${customsearchSetting.cols}'/> <input
        type="hidden" id="controls" name="controls" value='${customsearchSetting.controls}'/>
</form>
<div class="mtcontent">
    <div class="mtrow">
        <div class="mtcolall">
            <table id="student">
            </table>
        </div>

    </div>
    <div class="mtrow">
        <div class="mtcolall">
            <table id="control">
            </table>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript">
    var subGrid = null;
    var option = {}
    var subGridCols = [{
        field: "title",
        title: "标题名称",
        input: "<input></input>",
        width: "20%"
    }, {
        field: "field",
        title: "关联字段",
        input: "<input></input>",
        width: "20%"
    }, {
        field: "width",
        title: "列宽",
        input: "<input></input>",
        width: "15%"
    }, {
        field: "ifDisplay",
        title: "是否在列中显示",
        input: "<select><option value='0'>是</option><option value='1'>否</option></select>",
        width: "20%"
    }, {
        field: "ifResult",
        title: "是否返回值",
        input: "<select><option value='0'>是</option><option value='1'>否</option></select>",
        width: "20%"
    }, {
        field: "sn",
        title: "排序",
        input: "<input></input>",
        width: "5%"
    },];
    var subGridNullVal = {
        'title': '',
        'field': '',
        'width': '',
        'ifDisplay': '0',
        'ifResult': '0',
        'sn': '0'
    };

    var SubGridCon = null;
    var optionCon = {}
    var subGridColsCon = [{
        field: "controlName",
        title: "参数名称",
        input: "<input></input>",
        width: "20%"
    }, {
        field: "fieldName",
        title: "关联字段",
        input: "<input></input>",
        width: "20%"
    }, {
        field: "controlType",
        title: "参数类型",
        input: "<select><option value='0'>文本类型</option><option value='1'>日期类型</option><option value='2'>下拉选择</option><option value='3'>时间段</option></select>",
        width: "20%"
    }, {
        field: "qcDefault",
        title: "默认值",
        input: "<input></input>",
        width: "15%"
    }, {
        field: "fieldControl",
        title: "关联参数",
        input: "<input></input>",
        width: "15%"
    }, {
        field: "sn",
        title: "排序",
        input: "<input></input>",
        width: "10%"
    },];
    var subGridNullValCon = {
        'controlName': '',
        'fieldName': '',
        'controlType': '0',
        'qcDefault': '',
        'fieldControl': '',
        'sn': '1'
    };

    //=======================下发协议grid-end====================

    $(function () {
        if ($("#cols").val().length > 0 && $("#cols").val() != '[]') {
            subGrid = meeting.subgrid("#student", subGridCols, JSON.parse($("#cols").val()), option);
        } else {
            subGrid = meeting.subgrid("#student", subGridCols, [], option);
        }
        if ($("#controls").val().length > 0 && $("#controls").val() != '[]') {
            SubGridCon = meeting.subgrid("#control", subGridColsCon, JSON.parse($("#controls").val()), optionCon);
        } else {
            SubGridCon = meeting.subgrid("#control", subGridColsCon, [], option);
        }
    });

    function save() {
        $("#cols").val(JSON.stringify(subGrid.getAllRows()));
        $("#controls").val(JSON.stringify(SubGridCon.getAllRows()));
        return true;
    }
</script>
